class Solution
{
public:
    vector<vector<int>> queensAttacktheKing(vector<vector<int>> &queens, vector<int> &king)
    {
        vector<vector<int>> directrions = {
            {0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

        vector<vector<int>> result;
        for (auto &d : directrions)
        {
            int dx = d[0];
            int dy = d[1];
            int x = king[0];
            int y = king[1];
            while (true)
            {
                x += dx;
                y += dy;
                if (x < 0 || x >= 8)
                {
                    break;
                }
                if (y < 0 || y >= 8)
                {
                    break;
                }
                vector<int> k = {x, y};
                bool found = false;
                for (auto &q : queens)
                {

                    if (q == k)
                    {
                        result.push_back(q);
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }
        }
        return result;
    }
};